<template>
    <div class="content">
        <el-table class="content-list" border :data="data" style="width: 100%">
           
            <el-table-column prop="name" label="分类名称" />
          
         
            <el-table-column label="状态" width="100" >
                <template #default="scope">
                    <el-tag
                    v-if="scope.row.Content && scope.row.Content.status == 0"
                    type="info"
                    disable-transitions>已下线</el-tag>
                    <el-tag
                    v-else
                    type="success"
                    disable-transitions>正常</el-tag>
                </template>
            </el-table-column>
            
            <el-table-column label="操作">
                <template #default="scope">
                    <el-button
                        size="small"
                        :disabled="scope.row.index == 1"
                        @click="handleMove(scope.row.id,-1)"
                        >上移</el-button
                    >
                    <el-button
                        size="small"
                        :disabled="scope.row.index == pagination.total"
                        @click="handleMove(scope.row.id,1)"

                        >下移</el-button
                    >
                    <el-button size="small" 
                        >上架</el-button
                    >
                    <el-button size="small" 
                        >下架</el-button
                    >
                    <el-button
                        size="small"
                        type="primary"
                        >修改</el-button
                    >
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script setup>
import { ref } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { storeToRefs } from "pinia";
import { defineProps, defineEmits } from "vue";
import { url,staticUrl } from "@/services";
import { moveElement } from "@/utils/util";
import { updateTypeIndex } from "../../../services/type";
const prefixUrl = ref(staticUrl);

const props = defineProps(["data","pagination"]);
const emit = defineEmits(["show"]);

async function handleMove(id,val) {
    await updateTypeIndex(id,val);
    emit("show");
}

async function handleDelete(id) {
    ElMessageBox.confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
    }).then(async () => {
        emit("show");
    });
}
</script>
<style>
.content {
    padding-bottom: 50px;
}
.content-list {
    /* margin-top: 25px; */
    margin-bottom: 15px;
}
</style>
